import React, {
  Component
} from 'react';
import {
  BrowserRouter as Router,
  Route
} from 'react-router-dom';
import Index from '../components/index/index.jsx';
import UserList from '../components/UserList/index.jsx'
import User from '../components/User/index.jsx'
import EmployeeDetail from '../components/User/detail.jsx'
import Customer from '../components/customer/index.jsx'
import AccountDetail from '../components/customer/detail.jsx'

const BaseUrl = '/webBoss'

const routes = [ // 构建全局路由
  {
    path: '/index',
    component: Index
  },
  {
    path: '/userList',
    component: UserList
  },
  {
    path: '/user',
    component: User
  },
  {
    path: '/customer',
    component: Customer
  },
  {
    path: '/employeeDetail',
    component: EmployeeDetail
  },
  {
    path: '/customerDetail',
    component: AccountDetail
  }
]

const RouteWithSubRoutes = (route) => (
<Route path={BaseUrl + route.path} exact render={props => (
    // pass the sub-routes down to keep nesting
      <route.component {...props} routes={route.routes} />
)
}
/>
)

// const getConfirmation = (message, callback) => {
//   const allowTransition = window.confirm(message)
//   // callback(allowTransition)
// }
export default class BasicExample extends Component {
  constructor(props) {
    super(props)
    this.state = {
      author: '小小雪'
    }
  }
  render() {
    return (
      <Router>
        <div className='main-content'>
          <div className='clearfix'>
            {
              routes.map((route, i) => (
                <RouteWithSubRoutes key={i} {...route}/>
              ))
            }
          </div>
        </div>
      </Router>
    )
  }
}
